﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using WMS.FC.Domain.PersistenceObject.Business;
using WMS.FC.Infrastructure.Common;

namespace WMS.FC.Infrastructure.POConfig.Business
{
    public class MaterialTrayCellConfig : POBaseConfig<MaterialTrayCellPO>
    {
        public override void InitializeData(EntityTypeBuilder<MaterialTrayCellPO> builder)
        {
        }

        public override void MapColumn(EntityTypeBuilder<MaterialTrayCellPO> builder, ref int index)
        {
            builder.HasComment("托盘物料绑定电池物料表");
            builder.Property(entity => entity.TrayMaterialCode).ConfigColumn("TRAY_MATERIAL_CODE", "托盘物料编码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.CellMaterialCode).ConfigColumn("CELL_MATERIAL_CODE", "电池物料编码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.WarehouseCode).ConfigColumn("WAREHOUSE_CODE", "仓库编码", 50, true).HasColumnOrder(index++);
        }

        public override void MapIndex(EntityTypeBuilder<MaterialTrayCellPO> builder)
        {
            builder.HasIndex(entity => new { entity.TrayMaterialCode, entity.WarehouseCode }).HasDatabaseName($"IDX_{TableName}_1");
        }
    }
}
